package com.jiazhong.project.servlet;

import com.jiazhong.project.pojo.Brand;
import com.jiazhong.project.service.BrandService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/selectBrandById")
public class SelectBrandById extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       //获取前端的id
        final String id = req.getParameter("id");
        //调用方法
        BrandService brandService=new BrandService();
        final Brand brand = brandService.selectByIdBrand(Integer.parseInt(id));
        //把得到的对象放在域中
        req.setAttribute("brand",brand);
        //把数据转发到jsp
        req.getRequestDispatcher("/updatebrand.jsp").forward(req,resp);
    }
}
